package su.samcom.calc.model.dao;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;
import su.samcom.calc.model.entity.Price;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Владислав
 * Date: 24.11.13
 * Time: 12:40
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class PricePointDaoImpl extends BaseDaoImpl<Price> implements PricePointDao {

    @Override
    protected Class<Price> getGeneric() {
        return Price.class;
    }

    @Override
    public List<Price> getByPriceGroupId(Long id) {
        String sql = "select p from Price p where p.priceGroup.id = :priceGroupId order by p.price asc";
        Query query = sessionFactory.getCurrentSession().createQuery(sql);
        query.setParameter("priceGroupId", id);
        return query.list();
    }
}
